Trunc

The Trunc function. This function lets you replace a linear function of the input value by the closest integer which is less than this linear function, multiplied by a constant. By adjusting the parameters, you can create a large variety of round-off rules. Assume, e.g., that you want to replace the input value by the closest multiple of 0.5 which is less than the input value. To do this, enter 0.5 into the “a” field, 2 into the “b” field, and 0 into the “c” field.

More generally, let A be a positive number. To replace the input value by the closest multiple of A which is less than the input value, enter A into the “a” field, 1/A into the “b” field, and 0 into the “c” field. 

Similarly, let B be a negative number. To replace the input value by the closest multiple of B which is greater than the input value, enter B into the “a” field, 1/B into the “b” field, and 0 into the “c” field.

Default parameter values:

a = 1, b = 1, c = 0

Example:

a = 10, b = 0.1, c = 0

Input = 42  =>  Output = 40

Input = 56  =>  Output = 50